package com.api.oa.mapper;

import com.api.oa.model.entity.YQServiceOpt;
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface YQServiceOptMapper {

    @Insert("insert into  yq_service_opt  (" +
        "serviceName," +
        "insCode," +
        "createdAt" +
    ") " +
    "values " +
    "(" +
        "#{entity.serviceName}," +
        "#{entity.insCode}," +
        "#{entity.createdAt}" +
    ")" )
    @Options(useGeneratedKeys = true, keyProperty = "serviceId", keyColumn = "id")
    Integer insert(@Param("entity") YQServiceOpt entity);



    @Update("update  yq_service_opt  set " +
        "serviceName = #{entity.serviceName}" +
    " where serviceId = #{entity.serviceId}")
    Integer update(@Param("entity") YQServiceOpt  entity);


    @Delete("delete from yq_service_opt where serviceId=#{id}")
    void delete(@Param("id") Long id);


    @Select("<script> select * from  yq_service_opt  where 1 =1 <if test='id!=null and id!=\"\"'> and insCode = #{id} </if> </script>")
    List<YQServiceOpt> list(@Param("id") String insCode);


    @Select("<script> select * from  yq_service_opt  where 1 = 1 <if test='id!=null and id!=\"\"'> and serviceId in " +
            "  <foreach item='item' index='index' collection='id' open='(' separator=',' close=')'>#{item}" +
            "    </foreach>  </if> </script>")
    List<YQServiceOpt> listOpts(@Param("id") List<String> id);


    @Select("select * from  yq_service_opt  where serviceId = #{id} limit 1")
    YQServiceOpt findOne(@Param("id") Long id);

}

